package net.csdra.libraryborrowing.service.user;

import net.csdra.libraryborrowing.domain.user.User;

import java.nio.file.AccessDeniedException;

/**
 * Created by msf on 2017/10/11.
 */
public interface UserService {
    /**
     * 强制修改密码，用于忘记密码,调用者必须保证安全
     * 1，根据传入参数userName和currentOpenId联合查询是否数据库存在此用户。
     * 2，修改密码
     *
     * @param resetPassword
     * @return
     */
    public User weiXinResetPassword(WeiXinResetPassword resetPassword);

    /**
     * 使用用户名和密码登陆,
     *
     * @param login
     * @return user
     */
    public User login(Login login);

    /**
     * 使用微信登陆
     * 使用openId查询user，如果存在返回user
     *
     * @param weiXinLogin
     * @return
     */
    public User weiXinLogin(WeiXinLogin weiXinLogin) throws AccessDeniedException;

    /**
     * 修改当前用户信息
     *
     * @param updateUser
     * @return
     */
    public User updateUser(UpdateUser updateUser) throws AccessDeniedException;

    /**
     * 绑定openId
     * 1，根据userNam和password查询用户，
     * 2，如果用户openId有值，抛错提示已绑定
     * 3，存入数据库
     *
     * @param bindUserOpenId
     * @return
     */
    public User bindUserOpenId(BindUserOpenId bindUserOpenId);

    /**
     * 解除openId绑定，重置openId字段为空字符串
     * 1，根据userName和password验证是否存在用户
     * 2，（1，为真时）修改openId字段值为空
     * 3，返回修改user
     *
     * @param unBindUserOpenId
     * @return
     */
    public User unBindUserOpenId(UnBindUserOpenId unBindUserOpenId);


    public UserForm getUserById(UserManageService.GetUserById getUserById);


    class WeiXinResetPassword {
        String userName;
        CharSequence newPassword;
        String currentOpenId;

        public String getCurrentOpenId() {
            return currentOpenId;
        }

        public void setCurrentOpenId(String currentOpenId) {
            this.currentOpenId = currentOpenId;
        }

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public CharSequence getNewPassword() {
            return newPassword;
        }

        public void setNewPassword(CharSequence newPassword) {
            this.newPassword = newPassword;
        }
    }

    class UpdateUser {
        CharSequence password;
        String nikiName;
        String cover;
        String customize;



        public CharSequence getPassword() {
            return password;
        }

        public void setPassword(CharSequence password) {
            this.password = password;
        }

        public String getNikiName() {
            return nikiName;
        }

        public void setNikiName(String nikiName) {
            this.nikiName = nikiName;
        }

        public String getCover() {
            return cover;
        }

        public void setCover(String cover) {
            this.cover = cover;
        }

        public String getCustomize() {
            return customize;
        }

        public void setCustomize(String customize) {
            this.customize = customize;
        }
    }

    class Login {
        String userName;
        CharSequence password;

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public CharSequence getPassword() {
            return password;
        }

        public void setPassword(CharSequence password) {
            this.password = password;
        }
    }

    class WeiXinLogin {
        String openId;

        public String getOpenId() {
            return openId;
        }

        public void setOpenId(String openId) {
            this.openId = openId;
        }
    }

    class BindUserOpenId {
        String userName;
        CharSequence password;
        String openId;

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public CharSequence getPassword() {
            return password;
        }

        public void setPassword(CharSequence password) {
            this.password = password;
        }

        public String getOpenId() {
            return openId;
        }

        public void setOpenId(String openId) {
            this.openId = openId;
        }
    }

    class UnBindUserOpenId {
        String userName;
        CharSequence password;

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public CharSequence getPassword() {
            return password;
        }

        public void setPassword(CharSequence password) {
            this.password = password;
        }
    }

    class UserForm {
        String nikiName;
        String cover;
        String customize;

        public String getNikiName() {
            return nikiName;
        }

        public void setNikiName(String nikiName) {
            this.nikiName = nikiName;
        }

        public String getCover() {
            return cover;
        }

        public void setCover(String cover) {
            this.cover = cover;
        }

        public String getCustomize() {
            return customize;
        }

        public void setCustomize(String customize) {
            this.customize = customize;
        }
    }
}
